package com.ssm.student.service.impl;

import com.ssm.student.dao.ItemBankMapper;
import com.ssm.student.model.ItemBank;
import com.ssm.student.service.ItemBankService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 *实现业务及流程当中的内容
 */
@Service
public class ItemBankServiceImpl implements ItemBankService {
    @Autowired
    private ItemBankMapper itemBankMapper;
    @Override
    public int AddItemBank(ItemBank itemBank) {
        int returnInt=0;
        /*1.业务判断
        （1）名不能重复

        （1）判断角色
        * */
        int TopictypesCount=0;
        TopictypesCount=itemBankMapper.getTopictypes(itemBank.getTopictypes());
        if (TopictypesCount<1){
            //2.数据添加
            int addLoginLogInt=itemBankMapper.insertItemBank(itemBank);
            //3.返回值设置
            returnInt=addLoginLogInt;

        }else {
            returnInt=-1;//有相同的角色名称
        }
        return returnInt;
    }


    @Override
    public int UpdateItemBank(ItemBank itemBank) {
        int isUpdate=0;
        /*1.没有业务流程的判断*/
        try{
            isUpdate=itemBankMapper.updateItemBank(itemBank);
        }catch (Exception e){
            isUpdate=-1;
            //打印更新报错的情况
            System.out.println("更新角色信息时执行SQL报错的原因"+e.getMessage());
        }
        return isUpdate;
    }

    @Override
    public int DeleteItemBank(int itembankid) {
        int delRole=0;
        /*1.有关业务流程的判断*/

        try {
            //
        }catch (Exception e){
            delRole=-1;
            System.out.println("删除角色信息时执行SQL报错原因为"+e.getMessage());
        }
        return delRole;
    }
}


